package leader.action;

import java.text.SimpleDateFormat;
import java.util.Date;

import leader.service.DirectAwardService;

import teacher.bean.Award;
import teacher.bean.Flow;
import teacher.service.award;
import teacher.service.flow;

public class DirectAwardCheckAction {
	private Award award;

	public Award getAward() {
		return award;
	}

	public void setAward(Award award) {
		this.award = award;
	}
	public String execute() {
//		流程管理开始
		Award a=new Award();
		a=new award().selectAwardById(award.getAwaId());
		SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Flow f=new Flow();
		f.setFruitId(a.getAwaId());
		f.setFruitKind(3);
		f.setDirDo(0);
		f.setDirTime(df.format(new Date()));
		f.setSubDo(2);
		f.setSubTime(df.format(new Date()));
		f.setTeaDo(2);
		f.setTeaTime(df.format(new Date()));
//		流程管理结束
		if( new flow().insertFlow(f)){
			 award.setState(4);
				DirectAwardService AS = new DirectAwardService();
				AS.updateAwardState(award);
				return "success";
		 }else{
			 award.setState(4);
				DirectAwardService AS = new DirectAwardService();
				AS.updateAwardState(award);
				return "success";
		 }

	}
}
